package com.backend.securitiessystem.controller;

import com.backend.securitiessystem.dto.CapitalFlowDto;
import com.backend.securitiessystem.pojo.CapitalFlow;
import com.backend.securitiessystem.result.Result;
import com.backend.securitiessystem.service.CapitalFlowService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;

import lombok.extern.slf4j.Slf4j;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 港股通资金流 controller
 *
 * @author LWY
 * @date 2024-05-21 03:36:04
 */
@RestController
@Slf4j
public class CapitalFlowController {
    @Resource
    private CapitalFlowService iTbCapitalFlowService;


    @GetMapping("/getCashflowByPage")
    public Result<IPage<CapitalFlowDto>> getNewShareBypage(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "4") Integer pageSize
    ) {

        QueryWrapper<CapitalFlow> queryWrapper = new QueryWrapper<>();

        IPage<CapitalFlowDto> capitalFlowDtoIPage = iTbCapitalFlowService
                .selectPageWithCondition(pageNum, pageSize, queryWrapper);

        log.info("获取港股通资金流分页数据: {}", capitalFlowDtoIPage);
        return Result.success(capitalFlowDtoIPage);
    }
}
